<html>
<head><meta charset="utf-8"><title>transmutability · t-lang · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/index.html">t-lang</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html">transmutability</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="225921653"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/225921653" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Wrenn <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#225921653">(Feb 10 2021 at 22:30)</a>:</h4>
<p><span class="user-mention" data-user-id="239881">@Josh Triplett</span> recently touched based with me about next steps for a transmutability RFC. This proposal is the result of that conversation: <a href="https://jswrenn.github.io/transmutation-foundation">https://jswrenn.github.io/transmutation-foundation</a></p>



<a name="225922748"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/225922748" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#225922748">(Feb 10 2021 at 22:39)</a>:</h4>
<p>iirc <code>Neglect { &lt;field&gt;: &lt;value&gt;, ..v }</code> doesn't work outside the local crate when <code>Neglect</code> is <code>#[non_exhaustive]</code></p>



<a name="225923988"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/225923988" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#225923988">(Feb 10 2021 at 22:51)</a>:</h4>
<p>In the auditing chapter, the use of <code>transmute!(v, Neglect { validity })</code> should be <code>unsafe</code>, right?</p>



<a name="225924706"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/225924706" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Ashley Mannix <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#225924706">(Feb 10 2021 at 22:56)</a>:</h4>
<p><span class="user-mention" data-user-id="219211">@Jack Wrenn</span> That new proposal looks good to me! The const <code>Neglect</code> in particular I think is a nice change</p>



<a name="225924998"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/225924998" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Wrenn <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#225924998">(Feb 10 2021 at 22:59)</a>:</h4>
<p><span class="user-mention silent" data-user-id="229517">Jacob Lifshay</span> <a href="#narrow/stream/213817-t-lang/topic/transmutability/near/225922748">said</a>:</p>
<blockquote>
<p>iirc <code>Neglect { &lt;field&gt;: &lt;value&gt;, ..v }</code> doesn't work outside the local crate when <code>Neglect</code> is <code>#[non_exhaustive]</code></p>
</blockquote>
<p>I noticed that. Is that limitation just an over-zealous lint? There isn't any stability hazard there that I can see.</p>



<a name="225926775"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/225926775" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#225926775">(Feb 10 2021 at 23:15)</a>:</h4>
<p>functional update syntax should work even for non_exhaustive</p>



<a name="225927371"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/225927371" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#225927371">(Feb 10 2021 at 23:20)</a>:</h4>
<p><span class="user-mention silent" data-user-id="219211">Jack Wrenn</span> <a href="#narrow/stream/213817-t-lang/topic/transmutability/near/225924998">said</a>:</p>
<blockquote>
<p>I noticed that. Is that limitation just an over-zealous lint? There isn't any stability hazard there that I can see.</p>
</blockquote>
<p>This is the classic "FRU doesn't work like everyone expects".</p>
<p>The desugar moves all the fields that aren't mentioned, and <code>non_exhaustive</code> doesn't promise that those will be public.</p>



<a name="225927477"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/225927477" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#225927477">(Feb 10 2021 at 23:21)</a>:</h4>
<p>oh, just impl Copy on the type then?</p>



<a name="225927566"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/225927566" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#225927566">(Feb 10 2021 at 23:22)</a>:</h4>
<p>I don't think that fixes it.  Copy can still have private fields.</p>



<a name="225927688"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/225927688" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#225927688">(Feb 10 2021 at 23:23)</a>:</h4>
<p>but update syntax should work even with private fields. shouldn't it? That's how the raw-window-handle crate works</p>



<a name="225927753"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/225927753" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#225927753">(Feb 10 2021 at 23:24)</a>:</h4>
<p>(For example, it can be copy but maintain in invariant between the private field and the public one, which could be violated by FRU)</p>



<a name="225927767"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/225927767" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#225927767">(Feb 10 2021 at 23:24)</a>:</h4>
<p>No, FRU syntax doesn't work with inaccessible fields.</p>



<a name="225927810"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/225927810" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#225927810">(Feb 10 2021 at 23:24)</a>:</h4>
<p>If it did, you could <code>Vec { .. }</code> in safe code for a double-free.</p>



<a name="225927852"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/225927852" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#225927852">(Feb 10 2021 at 23:25)</a>:</h4>
<p>i... what. but there is not a source there</p>



<a name="225927876"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/225927876" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#225927876">(Feb 10 2021 at 23:25)</a>:</h4>
<p>Sorry, I meant <code>Vec { ..v }</code>.</p>



<a name="225928026"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/225928026" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#225928026">(Feb 10 2021 at 23:26)</a>:</h4>
<p>ah, Hmm.</p>



<a name="225928066"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/225928066" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#225928066">(Feb 10 2021 at 23:27)</a>:</h4>
<p>I'd definitely like to see someone pick up changing the desugaring as an edition change, though.  People seem continually surprised by it.</p>



<a name="225928096"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/225928096" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#225928096">(Feb 10 2021 at 23:27)</a>:</h4>
<p>Here's a macro that does what you probably wish FRU does: <a href="https://internals.rust-lang.org/t/pre-pre-rfc-syntactic-sugar-for-default-default/13234/7?u=scottmcm">https://internals.rust-lang.org/t/pre-pre-rfc-syntactic-sugar-for-default-default/13234/7?u=scottmcm</a></p>



<a name="225928136"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/225928136" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#225928136">(Feb 10 2021 at 23:27)</a>:</h4>
<p>Might also work to add <code>const fn</code> builder functions for <code>Neglect</code> for each field.</p>



<a name="225928310"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/225928310" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#225928310">(Feb 10 2021 at 23:29)</a>:</h4>
<p>Could also check where Esteban is on their RFC (<a href="https://internals.rust-lang.org/t/pre-pre-rfc-syntactic-sugar-for-default-default/13234/75?u=scottmcm">https://internals.rust-lang.org/t/pre-pre-rfc-syntactic-sugar-for-default-default/13234/75?u=scottmcm</a>)</p>



<a name="225928352"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/225928352" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#225928352">(Feb 10 2021 at 23:29)</a>:</h4>
<p>Since that's about <code>Neglect { alignment: true, .. }</code>.</p>
<p>Though I guess that doesn't solve the <code>non_exhaustive</code> problem</p>



<a name="225928502"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/225928502" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#225928502">(Feb 10 2021 at 23:31)</a>:</h4>
<p>i guess the problem is that the source value isn't forgotten</p>



<a name="225928866"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/225928866" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#225928866">(Feb 10 2021 at 23:34)</a>:</h4>
<p>Is the example here right? I think as written it's not sound under any formulation, <a href="https://jswrenn.github.io/transmutation-foundation/unresolved-src-visibility.html">https://jswrenn.github.io/transmutation-foundation/unresolved-src-visibility.html</a></p>
<p>The example and its name make more sense as:</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="w">    </span><span class="k">pub</span><span class="w"> </span><span class="k">fn</span> <span class="nf">as_bytes</span><span class="o">&lt;'</span><span class="na">t</span><span class="p">,</span><span class="w"> </span><span class="n">T</span><span class="o">&gt;</span><span class="p">(</span><span class="n">t</span>: <span class="kp">&amp;</span><span class="o">'</span><span class="na">t</span> <span class="nc">T</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="kp">&amp;</span><span class="o">'</span><span class="na">t</span> <span class="p">[</span><span class="kt">u8</span><span class="p">]</span><span class="w"></span>
<span class="w">    </span><span class="k">where</span><span class="w"></span>
<span class="w">        </span><span class="n">T</span>: <span class="nc">upstream</span>::<span class="n">POD</span><span class="p">,</span><span class="w"></span>
<span class="w">    </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="k">use</span><span class="w"> </span><span class="n">core</span>::<span class="p">{</span><span class="n">slice</span><span class="p">,</span><span class="w"> </span><span class="n">mem</span>::<span class="n">size_of</span><span class="p">};</span><span class="w"></span>

<span class="w">        </span><span class="k">unsafe</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">            </span><span class="n">slice</span>::<span class="n">from_raw_parts</span><span class="p">(</span><span class="n">t</span><span class="w"> </span><span class="k">as</span><span class="w"> </span><span class="o">*</span><span class="k">const</span><span class="w"> </span><span class="n">T</span><span class="w"> </span><span class="k">as</span><span class="w"> </span><span class="o">*</span><span class="k">const</span><span class="w"> </span><span class="kt">u8</span><span class="p">,</span><span class="w"> </span><span class="n">size_of</span>::<span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="p">())</span><span class="w"></span>
<span class="w">        </span><span class="p">}</span><span class="w"></span>
<span class="w">    </span><span class="p">}</span><span class="w"></span>
</code></pre></div>
<p>or something like, that, rather than going fromf &amp;T to a slice of size_of::&lt;T&gt;() T's in a function named as_bytes</p>



<a name="225929204"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/225929204" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Wrenn <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#225929204">(Feb 10 2021 at 23:38)</a>:</h4>
<p>Whoops, yep, as-written that snippet is a compile error. <span aria-label="smile" class="emoji emoji-1f642" role="img" title="smile">:smile:</span></p>



<a name="225931086"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/225931086" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> rpjohnst <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#225931086">(Feb 10 2021 at 23:57)</a>:</h4>
<p>it may also be worth considering a multi-trait approach rather than a const generics approach- e.g. a trait for each individual property, plus trait aliases for "check everything" and "check everything except _"</p>



<a name="225931134"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/225931134" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> rpjohnst <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#225931134">(Feb 10 2021 at 23:57)</a>:</h4>
<p>that also naturally solves the ordering stuff (traits were essentially designed to do that, even more so than structs) but doesn't hit <code>non_exhaustive</code> problems.</p>



<a name="225931516"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/225931516" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> rpjohnst <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#225931516">(Feb 11 2021 at 00:01)</a>:</h4>
<p>the tradeoff would be that you can no longer be generic over different values for <code>Neglect</code></p>



<a name="225932570"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/225932570" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Wrenn <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#225932570">(Feb 11 2021 at 00:14)</a>:</h4>
<p>The <code>#[non_exhaustive] + FRU</code> issue strikes me as a minor ergonomic hiccup with a lot of possible resolutions. We <em>could</em> do nothing about it (you can start with <code>Neglect::NOTHING</code> and just set fields one-by-one), or resolve it with the builder pattern, or a macro, or even something like this:</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">impl</span><span class="w"> </span><span class="n">Neglect</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">pub</span><span class="w"> </span><span class="k">const</span><span class="w"> </span><span class="n">NOTHING</span>: <span class="nc">Self</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">Neglect</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="n">alignment</span><span class="w">   </span>: <span class="nc">false</span><span class="p">,</span><span class="w"></span>
<span class="w">        </span><span class="n">lifetimes</span><span class="w">   </span>: <span class="nc">false</span><span class="p">,</span><span class="w"></span>
<span class="w">        </span><span class="n">validity</span><span class="w">    </span>: <span class="nc">false</span><span class="p">,</span><span class="w"></span>
<span class="w">        </span><span class="n">visibility</span><span class="w">  </span>: <span class="nc">false</span><span class="p">,</span><span class="w"></span>
<span class="w">    </span><span class="p">};</span><span class="w"></span>

<span class="w">    </span><span class="k">pub</span><span class="w"> </span><span class="k">const</span><span class="w"> </span><span class="n">ALIGNMENT</span>:  <span class="nc">Self</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">Neglect</span><span class="w"> </span><span class="p">{</span><span class="n">alignment</span>: <span class="nc">true</span><span class="p">,</span><span class="w"> </span><span class="o">..</span><span class="bp">Self</span>::<span class="n">Nothing</span><span class="p">};</span><span class="w"></span>
<span class="w">    </span><span class="k">pub</span><span class="w"> </span><span class="k">const</span><span class="w"> </span><span class="n">LIFETIMES</span>:  <span class="nc">Self</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">Neglect</span><span class="w"> </span><span class="p">{</span><span class="n">lifetimes</span>: <span class="nc">true</span><span class="p">,</span><span class="w"> </span><span class="o">..</span><span class="bp">Self</span>::<span class="n">Nothing</span><span class="p">};</span><span class="w"></span>
<span class="w">    </span><span class="k">pub</span><span class="w"> </span><span class="k">const</span><span class="w"> </span><span class="n">LIFETIMES</span>:  <span class="nc">Self</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">Neglect</span><span class="w"> </span><span class="p">{</span><span class="n">validity</span>:  <span class="nc">true</span><span class="p">,</span><span class="w"> </span><span class="o">..</span><span class="bp">Self</span>::<span class="n">Nothing</span><span class="p">};</span><span class="w"></span>
<span class="w">    </span><span class="k">pub</span><span class="w"> </span><span class="k">const</span><span class="w"> </span><span class="n">VISIBILITY</span>: <span class="nc">Self</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">Neglect</span><span class="w"> </span><span class="p">{</span><span class="n">validity</span>:  <span class="nc">true</span><span class="p">,</span><span class="w"> </span><span class="o">..</span><span class="bp">Self</span>::<span class="n">Nothing</span><span class="p">};</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="k">impl</span><span class="w"> </span><span class="n">Add</span><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="n">Neglect</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">  </span><span class="k">fn</span> <span class="nf">add</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span><span class="w"> </span><span class="n">other</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="nc">Self</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">      </span><span class="n">Neglect</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">          </span><span class="n">alignment</span><span class="w">   </span>: <span class="nc">self</span><span class="p">.</span><span class="n">alignment</span><span class="w">  </span><span class="o">||</span><span class="w"> </span><span class="n">other</span><span class="p">.</span><span class="n">alignment</span><span class="p">,</span><span class="w"></span>
<span class="w">          </span><span class="n">lifetimes</span><span class="w">   </span>: <span class="nc">self</span><span class="p">.</span><span class="n">lifetimes</span><span class="w">  </span><span class="o">||</span><span class="w"> </span><span class="n">other</span><span class="p">.</span><span class="n">lifetimes</span><span class="p">,</span><span class="w"></span>
<span class="w">          </span><span class="n">validity</span><span class="w">    </span>: <span class="nc">self</span><span class="p">.</span><span class="n">validity</span><span class="w">   </span><span class="o">||</span><span class="w"> </span><span class="n">other</span><span class="p">.</span><span class="n">validity</span><span class="p">,</span><span class="w"></span>
<span class="w">          </span><span class="n">visibility</span><span class="w">  </span>: <span class="nc">self</span><span class="p">.</span><span class="n">visibility</span><span class="w"> </span><span class="o">||</span><span class="w"> </span><span class="n">other</span><span class="p">.</span><span class="n">visibility</span><span class="p">,</span><span class="w"></span>
<span class="w">      </span><span class="p">}</span><span class="w"></span>
<span class="w">  </span><span class="p">}</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>
<p>...which would allow you to write, e.g., <code>Neglect::ALIGNMENT + Neglect::VALIDITY</code>. I think that's looks even nicer than FRU.</p>



<a name="225932929"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/225932929" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#225932929">(Feb 11 2021 at 00:19)</a>:</h4>
<p><span class="user-mention" data-user-id="219211">@Jack Wrenn</span> That seems reasonable.</p>



<a name="225933062"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/225933062" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#225933062">(Feb 11 2021 at 00:20)</a>:</h4>
<p>Another possibility would be:</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">impl</span><span class="w"> </span><span class="n">Neglect</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">pub</span><span class="w"> </span><span class="k">const</span><span class="w"> </span><span class="n">NOTHING</span>: <span class="nc">Self</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">Neglect</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="n">alignment</span><span class="w">   </span>: <span class="nc">false</span><span class="p">,</span><span class="w"></span>
<span class="w">        </span><span class="n">lifetimes</span><span class="w">   </span>: <span class="nc">false</span><span class="p">,</span><span class="w"></span>
<span class="w">        </span><span class="n">validity</span><span class="w">    </span>: <span class="nc">false</span><span class="p">,</span><span class="w"></span>
<span class="w">        </span><span class="n">visibility</span><span class="w">  </span>: <span class="nc">false</span><span class="p">,</span><span class="w"></span>
<span class="w">    </span><span class="p">};</span><span class="w"></span>

<span class="w">    </span><span class="k">pub</span><span class="w"> </span><span class="k">const</span><span class="w"> </span><span class="k">fn</span> <span class="nf">alignment</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="nc">Self</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="n">Neglect</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="n">alignment</span>: <span class="nc">true</span><span class="p">,</span><span class="w"> </span><span class="o">..</span><span class="bp">self</span><span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="p">}</span><span class="w"></span>
<span class="w">    </span><span class="c1">// ...</span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>
<p>And then you could write <code>Neglect::NOTHING.alignment()</code></p>



<a name="225933232"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/225933232" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Wrenn <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#225933232">(Feb 11 2021 at 00:22)</a>:</h4>
<p>Slick! I'll be sure to add an entry in "Unresolved Questions" for these possibilities.</p>



<a name="225933273"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/225933273" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#225933273">(Feb 11 2021 at 00:23)</a>:</h4>
<p>FWIW, I'm <span aria-label="+1" class="emoji emoji-1f44d" role="img" title="+1">:+1:</span> on either of the above possibilities (as long as they're tested and confirmed to work), to avoid having to sort out FRU as a prerequisite.</p>



<a name="226023539"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/226023539" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Quy Nguyen <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#226023539">(Feb 11 2021 at 17:05)</a>:</h4>
<p><span class="user-mention silent" data-user-id="125270">scottmcm</span> <a href="#narrow/stream/213817-t-lang/topic/transmutability/near/225927753">said</a>:</p>
<blockquote>
<p>(For example, it can be copy but maintain in invariant between the private field and the public one, which could be violated by FRU)</p>
</blockquote>
<p>If the field is public, how can it be used for an invariant?</p>



<a name="226029487"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/226029487" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#226029487">(Feb 11 2021 at 17:44)</a>:</h4>
<p>Good point.  That was a bad example from me.</p>



<a name="226066547"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/226066547" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> rylev <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#226066547">(Feb 11 2021 at 22:18)</a>:</h4>
<p><span class="user-mention" data-user-id="219211">@Jack Wrenn</span> this is an awesome write up! It’s looking really great! In the example <a href="https://jswrenn.github.io/transmutation-foundation/scope-safety.html">about scope</a> shouldn’t the NonZeroU32::new function check that v isn’t zero? I think it’s important to point out that because it’s local to the type it can see private details and is obligated to respect invariants while the non-local variant has no idea what the invariants of the type are and can’t be expected to respect them.</p>



<a name="226066755"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/226066755" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> rylev <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#226066755">(Feb 11 2021 at 22:21)</a>:</h4>
<p>Also, is “unsound” the right term. As written the non local function is just as sound as the local, but of course this can change at any point if the implement of the type changes. It’s not “stably” sound.</p>



<a name="226066918"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/226066918" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> rylev <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#226066918">(Feb 11 2021 at 22:22)</a>:</h4>
<p>I know we’ve been back and forth on what words to use for these concepts because there doesn’t seem to be a clearly defined definition that’s used universally, but I think it’s important to make this as clear as possible</p>



<a name="226072315"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/226072315" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#226072315">(Feb 11 2021 at 23:14)</a>:</h4>
<p>they're both unsound</p>



<a name="226072384"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/226072384" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#226072384">(Feb 11 2021 at 23:15)</a>:</h4>
<p>instead of speaking of soundness, try just saying "allowed" or "disallowed"</p>



<a name="226072493"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/226072493" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#226072493">(Feb 11 2021 at 23:16)</a>:</h4>
<p>uh, just for the visibility example i mean</p>



<a name="226083512"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/226083512" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Quy Nguyen <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#226083512">(Feb 12 2021 at 01:36)</a>:</h4>
<p>I know this is off topic, but is there any reason it never got changed, besides inertia?</p>



<a name="226143163"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/226143163" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#226143163">(Feb 12 2021 at 14:31)</a>:</h4>
<p>that the word never got changed? It's a fine word, people just use it wrong sometimes. Every word gets used wrong sometimes.</p>



<a name="226172994"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/226172994" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Quy Nguyen <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#226172994">(Feb 12 2021 at 17:55)</a>:</h4>
<p>Oh, I meant FRU. I thought I had a quote there.</p>



<a name="226272341"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/226272341" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Wrenn <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#226272341">(Feb 13 2021 at 22:24)</a>:</h4>
<p>I've updated <a href="https://jswrenn.github.io/transmutation-foundation/introduction.html">the proposal</a> to account (I think) for everyone's feedback.</p>



<a name="226272356"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/226272356" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Wrenn <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#226272356">(Feb 13 2021 at 22:24)</a>:</h4>
<p><span class="user-mention silent" data-user-id="239881">Josh Triplett</span> <a href="#narrow/stream/213817-t-lang/topic/transmutability/near/225933273">said</a>:</p>
<blockquote>
<p>FWIW, I'm <span aria-label="+1" class="emoji emoji-1f44d" role="img" title="+1">:+1:</span> on either of the above possibilities (as long as they're tested and confirmed to work), to avoid having to sort out FRU as a prerequisite.</p>
</blockquote>
<p>I opted for the <code>Add</code> impl, since I think the meaning of the resulting code is more self-evident; consider:</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="n">Neglect</span>::<span class="n">NOTHING</span><span class="p">.</span><span class="n">alignment</span><span class="p">().</span><span class="n">validity</span><span class="p">()</span><span class="w"></span>
</code></pre></div>
<p>vs:</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="n">Neglect</span>::<span class="n">ALIGNMENT</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="n">Neglect</span>::<span class="n">VALIDITY</span><span class="w"></span>
</code></pre></div>



<a name="226290455"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/226290455" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#226290455">(Feb 14 2021 at 07:23)</a>:</h4>
<p><span class="user-mention" data-user-id="219211">@Jack Wrenn</span> Sounds good. I think the builder methods could be made more self-explanatory, if we renamed Nothing, but the add approach seems fine to me.</p>



<a name="226313913"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/226313913" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Wrenn <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#226313913">(Feb 14 2021 at 16:49)</a>:</h4>
<p>Glad to hear it. <span aria-label="smile" class="emoji emoji-1f642" role="img" title="smile">:smile:</span> Besides the extra <code>NOTHING</code>, something that tips the scales towards <code>+</code> for me is that there's a clearer mapping from syntax to semantics. <code>+</code> is pretty universally understood as an operator for combining things, and <code>.</code> provides a mechanism for accessing things. With the builder method approach, however, combination and access are _very_ syntactically similar:</p>
<ul>
<li><code>NEGLECT.validity()</code> extends <code>NEGLECT</code> with <code>validity: true</code></li>
<li><code>NEGLECT.validity</code> produces the <code>validity</code> field of <code>NEGLECT</code></li>
</ul>



<a name="226314148"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/226314148" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Wrenn <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#226314148">(Feb 14 2021 at 16:55)</a>:</h4>
<p><span class="user-mention" data-user-id="224872">@rylev</span> I also <a href="https://jswrenn.github.io/transmutation-foundation/scope-mechanism.html">tweaked the example</a> and added the clarification that:</p>
<blockquote>
<p>It's generally unsound to construct instances of types for which you do not have a constructor.</p>
</blockquote>
<p>I say "generally" because, as you pointed out, that particular example was <em>potentially</em> sound <em>at snapshot in time</em>, assuming you've done your diligence to ensure that conjuring up a constructor cannot possibly lead to memory unsafety. With relation to the broader proposal: if you neglect the visibility check, you're promising to the compiler that you're doing that due diligence.</p>



<a name="226320883"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/226320883" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#226320883">(Feb 14 2021 at 19:37)</a>:</h4>
<p>Minor bikeshed: I'd say <code>|</code>, not <code>+</code>, because that's how it's combining things internally anyway, and people are used to that for flags enums in lots of languages.  (<code>Neglect::ALIGNMENT + Neglect::ALIGNMENT</code> would be a silly thing to write, but a half adder does XOR, not OR.)</p>



<a name="226380335"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/226380335" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dirkjan Ochtman <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#226380335">(Feb 15 2021 at 12:55)</a>:</h4>
<p>Yeah, it looks like <code>|</code> makes more sense here (there's even a clippy lint that will warn about doing <code>|</code> in an impl of <code>Add</code>/<code>AddAssign</code>, IIRC)</p>



<a name="226413783"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/226413783" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Wrenn <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#226413783">(Feb 15 2021 at 17:53)</a>:</h4>
<p>I'm not so sure. Certainly <code>|</code> or <code>||</code> is more familiar to anyone who's done bit manipulation, but I think it might confuse people who aren't accustomed to manipulating bitsets. Consider that it's also useful to turn <em>off</em> options in some circumstances. A <code>Sub</code> impl provides a more natural surface syntax for doing so — <code>NEGLECT - Neglect::ALIGNMENT</code> — than the bit-manipulation equivalent.</p>



<a name="226427262"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/226427262" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bstrie <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#226427262">(Feb 15 2021 at 20:31)</a>:</h4>
<p>I see that the documention mentions that const generic default parameters aren't yet available, but it does seem like you could sidestep the whole pseudo-bitflags issue by leveraging that instead. <code>trait Foo&lt;Src, Scope, const Alignment: bool = false, const Lifetimes: bool = false, const Validity: bool = false, const Visibility: bool = false&gt;</code>. Is it worth waiting for this to work (it doesn't need to be stable) before comitting to an API?</p>



<a name="226430550"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/226430550" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Wrenn <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#226430550">(Feb 15 2021 at 21:12)</a>:</h4>
<p>I don't <em>think</em> so. The ergonomic cost and safety risk of having to correctly thread <em>N</em> const arguments strikes me as very high. (Consider if you messed up the order while threading these arguments through an impl; you'd inadvertently turn off the wrong static checks.)</p>
<p>I don't think the issue of what operator to provide is all that significant. We could provide both. Or, we could even provide neither <a href="https://jswrenn.github.io/transmutation-foundation/neglect-combining.html#alternative-minimalism">as described here</a>.</p>



<a name="226430975"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/226430975" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#226430975">(Feb 15 2021 at 21:19)</a>:</h4>
<p>Is the reason behind the polarity of <code>Neglect</code> documented somewhere? I.e. why not <code>Validate</code> with all the booleans flipped</p>



<a name="226431388"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/226431388" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Wrenn <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#226431388">(Feb 15 2021 at 21:24)</a>:</h4>
<p>Are you imagining that the starting point would be <code>Validate::ALL</code>? Then you'd <code>-</code> the checks you wanted to turn off? E.g.:</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="n">Validate</span>::<span class="n">ALL</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="n">Validate</span>::<span class="n">ALIGNMENT</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="n">Validate</span>::<span class="n">VALIDITY</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="n">etc</span><span class="o">..</span><span class="p">.</span><span class="w"></span>
</code></pre></div>



<a name="226431392"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/226431392" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#226431392">(Feb 15 2021 at 21:24)</a>:</h4>
<p>yeah</p>



<a name="226431425"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/226431425" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#226431425">(Feb 15 2021 at 21:25)</a>:</h4>
<p>since it is in some sense the more obvious way to state things, I assume it was avoided for a reason</p>



<a name="226433127"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/226433127" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Wrenn <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#226433127">(Feb 15 2021 at 21:48)</a>:</h4>
<p>The polarity is, in part, a holdover from when <code>Neglect</code> was represented as a defaulted type parameter. With that representation, it was crucial the that the default wouldn't ever need to be changed if additional neglectable checks were ever added. "Neglect nothing" provided that stable default.</p>
<p>I can think of two aesthetic/ergonomic considerations, though:</p>
<p>First: turning off static checks should <em>scream</em> "I need to verify this property myself." I think the appearance of the word <code>neglect</code> is alarming in a way that "validate" isn't. If the polarity goes the other way, the occurrence of <code>Validate::ALIGNMENT</code> actually means that alignment <em>isn't</em> validated.</p>
<p>Second: the ergonomics of neglect might be slightly better than validate. Contrast this:   </p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="n">Validate</span>::<span class="n">ALL</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="n">Validate</span>::<span class="n">ALIGNMENT</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="n">Validate</span>::<span class="n">VALIDITY</span><span class="w"></span>
</code></pre></div>
<p>...with: </p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="n">Neglect</span>::<span class="n">ALIGNMENT</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="n">Neglect</span>::<span class="n">VALIDITY</span><span class="w"></span>
</code></pre></div>
<p>Most of the time, <code>Validate::ALL</code> is just extra line noise.</p>



<a name="226849623"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/226849623" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Wrenn <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#226849623">(Feb 18 2021 at 17:42)</a>:</h4>
<p>Another good name for <code>Neglect</code> might be <code>Assume</code>, since you're enumerating the properties that the compiler can assume to be true when checking the soundness of a transmute.</p>



<a name="226861771"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/226861771" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#226861771">(Feb 18 2021 at 19:00)</a>:</h4>
<p><code>Bypass</code><br>
<code>Skip</code></p>



<a name="226864960"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/226864960" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> rylev <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#226864960">(Feb 18 2021 at 19:20)</a>:</h4>
<p><code>Unchecked</code> the term "unchecked" is often used to connote something is not verified by the compiler.</p>



<a name="226866076"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/226866076" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#226866076">(Feb 18 2021 at 19:27)</a>:</h4>
<p>I like "assume" because it has the connotation that you're telling it to assume something without checking.</p>



<a name="226870239"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/226870239" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#226870239">(Feb 18 2021 at 19:55)</a>:</h4>
<p>"without checking" also sounds like Unchecked though</p>



<a name="226870475"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/226870475" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> rylev <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#226870475">(Feb 18 2021 at 19:57)</a>:</h4>
<p><a href="https://doc.rust-lang.org/stable/std/?search=unchecked">https://doc.rust-lang.org/stable/std/?search=unchecked</a><br>
<a href="https://doc.rust-lang.org/stable/std/?search=assume">https://doc.rust-lang.org/stable/std/?search=assume</a></p>



<a name="226872302"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/226872302" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Daniel Henry-Mantilla <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#226872302">(Feb 18 2021 at 20:09)</a>:</h4>
<p><span class="user-mention silent" data-user-id="224872">rylev</span> <a href="#narrow/stream/213817-t-lang/topic/transmutability/near/226870475">said</a>:</p>
<blockquote>
<p><a href="https://doc.rust-lang.org/stable/std/?search=unchecked">https://doc.rust-lang.org/stable/std/?search=unchecked</a><br>
<a href="https://doc.rust-lang.org/stable/std/?search=assume">https://doc.rust-lang.org/stable/std/?search=assume</a></p>
</blockquote>
<p>From that search stems the fact that <strong><code>unchecked</code> is used when there are checked alternatives / counterparts</strong>; so it could make sense to use stuff like <code>Unchecked::Alignment</code> given how not giving that parameter will (statically) check the alignment; that being said, the fact the checks only operate statically actually make me lean in the other direction, actually: for instance, if you want to cast a <code>&amp;[u8; 2]</code> to a <code>&amp;[u16; 1]</code>, then you'd need to manually check the alignment and then <code>Assume::Alignment</code> since there would be no checked counterpart (IIUC, the runtime-checked counterparts <em>a la</em> <code>bytemuck</code> would be downstream users of this foundation).</p>



<a name="228312285"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/228312285" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> rylev <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#228312285">(Mar 01 2021 at 21:50)</a>:</h4>
<p><span class="user-mention" data-user-id="219211">@Jack Wrenn</span> <span class="user-mention" data-user-id="239881">@Josh Triplett</span>: what should we do to push things forward? Should the RFC be updated? Is the proposal far enough along that we should start getting an unstable implementation in the compiler?</p>



<a name="228315377"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/228315377" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Wrenn <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#228315377">(Mar 01 2021 at 22:10)</a>:</h4>
<p>My feeling is that the current RFC should be closed, rather than updated. Then, this proposal should probably be reformulated to fit the format of an RFC (or an MCP) and submitted as such.</p>



<a name="228317122"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/228317122" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> rylev <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#228317122">(Mar 01 2021 at 22:21)</a>:</h4>
<p>Any thoughts on starting implementation? There does seem to be parts of the proposal that aren’t too controversial and/or can be changed quickly</p>



<a name="228319215"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/228319215" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#228319215">(Mar 01 2021 at 22:36)</a>:</h4>
<p>It seems like the most important starting point for the implementation is the compiler-supplied underlying trait, with lots of tests to demonstrate that it implements the rules as designed. Layers atop that can be demonstrated atop the resulting try builds and later nightlies.</p>



<a name="228319987"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/228319987" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#228319987">(Mar 01 2021 at 22:42)</a>:</h4>
<p>As for next steps, I think it's up to this group whether it makes sense to update or rewrite the RFC. But either way, I think that the team will want to evaluate the new version standalone, together with the various clear explanations I've seen from this group and the recent documents.</p>



<a name="228322268"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/228322268" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#228322268">(Mar 01 2021 at 23:01)</a>:</h4>
<p><span class="user-mention silent" data-user-id="224872">rylev</span> <a href="#narrow/stream/213817-t-lang/topic/transmutability/near/228312285">said</a>:</p>
<blockquote>
<p>Is the proposal far enough along that we should start getting an unstable implementation in the compiler?</p>
</blockquote>
<p>T-compiler would have to approve it, of course, but I think making the "needs to be in the compiler" trait part as available as unstable soon -- even before a new RFC is posted, perhaps -- makes a ton of sense.</p>
<p>Then it would be possible to have playground demos or similar of the wrapper proposals</p>



<a name="228410873"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/228410873" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> rylev <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#228410873">(Mar 02 2021 at 13:43)</a>:</h4>
<p><span class="user-mention" data-user-id="219211">@Jack Wrenn</span> Do you want to ask <a class="stream" data-stream-id="131828" href="/#narrow/stream/131828-t-compiler">#t-compiler</a> if the think an MCP would be appropriate for getting the go-ahead on an unstable safe transmute <code>BikeshedIntrinsicFrom</code> in the compiler? I can help here if you want.</p>



<a name="228460554"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/228460554" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Wrenn <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#228460554">(Mar 02 2021 at 18:28)</a>:</h4>
<p>Just to confirm: are MCP's the right tool for this? The <a href="https://forge.rust-lang.org/compiler/mcp.html">docs</a> stress that they're mostly for non-user-facing changes.</p>



<a name="228473837"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/228473837" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#228473837">(Mar 02 2021 at 19:51)</a>:</h4>
<p>Yes, because the RFC will be the user-facing side of this.  Right now it's just adding an implementation detail.</p>
<p>(This is like adding an intrinsic, even if that intrinsic is something that might be exposed stably in the future.)</p>



<a name="228477070"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/228477070" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Wrenn <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#228477070">(Mar 02 2021 at 20:10)</a>:</h4>
<p>Great!</p>



<a name="228482482"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/228482482" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Wrenn <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#228482482">(Mar 02 2021 at 20:44)</a>:</h4>
<p>How much of <a href="https://jswrenn.github.io/transmutation-foundation/">the mdbook</a> should go into the MCP vs being linked?</p>



<a name="228484279"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/228484279" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#228484279">(Mar 02 2021 at 20:57)</a>:</h4>
<p>My guess is that it would include only the parts relevant to <code>BikeshedIntrinsicFrom</code>, like "When is a transmutation well-defined and safe?", but with everything about muckable and other such things only referenced.  But you might want to start a t-compiler thread about it -- I'm just extrapolating from things I've seen, as I haven't made one nor can I second them.</p>



<a name="228558842"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/228558842" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> rylev <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#228558842">(Mar 03 2021 at 09:10)</a>:</h4>
<p>In my experience MCPs tend to be focused on the actual proposal with relevant context in adjacent documents.</p>



<a name="228818885"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/228818885" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Wrenn <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#228818885">(Mar 04 2021 at 17:51)</a>:</h4>
<p><span class="user-mention" data-user-id="224872">@rylev</span> how's this: <a href="https://github.com/jswrenn/transmutation-foundation/blob/main/MCP.md">https://github.com/jswrenn/transmutation-foundation/blob/main/MCP.md</a></p>



<a name="228820110"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/228820110" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> rylev <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#228820110">(Mar 04 2021 at 17:59)</a>:</h4>
<p>Awesome! I would add a short sentence at the very beginning saying this is part of the safe transmute working group's investigation and link to the RFC</p>



<a name="228820530"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/228820530" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> rylev <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#228820530">(Mar 04 2021 at 18:00)</a>:</h4>
<p>I'm not sure that the level of detail is needed. After all, it's not really about whether they thing the design is a good one. It's more a request "the safe transmute WG thinks this is the right direction, but we'd like to experiment in the compiler"</p>



<a name="228826071"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/228826071" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#228826071">(Mar 04 2021 at 18:34)</a>:</h4>
<p>Nit: add Debug/Clone/Copy/Default for Assume</p>



<a name="228828705"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/228828705" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Wrenn <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#228828705">(Mar 04 2021 at 18:50)</a>:</h4>
<p><code>Clone</code> and <code>Copy</code> are no-brainers (just added them!), but <code>Default</code> is debatable. <code>Assume::NOTHING</code> is clearer than <code>Assume:default()</code>. Also, I don't think <code>Default</code> can be used in a const context, which is where <code>Assume</code> is mostly going to be used.</p>



<a name="228829026"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/228829026" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Wrenn <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#228829026">(Mar 04 2021 at 18:52)</a>:</h4>
<p><span class="user-mention silent" data-user-id="224872">rylev</span> <a href="#narrow/stream/213817-t-lang/topic/transmutability/near/228820110">said</a>:</p>
<blockquote>
<p>Awesome! I would add a short sentence at the very beginning saying this is part of the safe transmute working group's investigation and link to the RFC</p>
</blockquote>
<p>Done! I didn't add the link to the RFC in that intro sentence, though, since it's not really required reading and the <em>volume</em> of reading is pretty overwhelming. There's a link to it at the end.</p>



<a name="228829169"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/228829169" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Wrenn <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#228829169">(Mar 04 2021 at 18:53)</a>:</h4>
<p>I included the explanations because  <span class="user-mention silent" data-user-id="239881">Josh Triplett</span> <a href="#narrow/stream/213817-t-lang/topic/transmutability/near/228319987">mentioned</a> them as important:</p>
<blockquote>
<p>As for next steps, I think it's up to this group whether it makes sense to update or rewrite the RFC. But either way, I think that the team will want to evaluate the new version standalone, together with the various clear explanations I've seen from this group and the recent documents.</p>
</blockquote>
<p>I <em>think</em> the explanations I included are more so along the lines of "why does this bit need to exist" (which might be important for review), rather than "what's the optimal form this bit should exist in". </p>
<p>I've added a note marking the transition from proposal to explanation.</p>



<a name="228829650"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/228829650" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Wrenn <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#228829650">(Mar 04 2021 at 18:56)</a>:</h4>
<p>I'm going to go ahead and file the MCP! I can always trim the explanation out if need be. <span aria-label="smile" class="emoji emoji-1f642" role="img" title="smile">:smile:</span></p>
<p><strong><em>kapow!</em></strong> <a href="https://github.com/rust-lang/compiler-team/issues/411">https://github.com/rust-lang/compiler-team/issues/411</a></p>



<a name="228915159"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/228915159" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#228915159">(Mar 05 2021 at 08:40)</a>:</h4>
<p>Nice to see movement here. :)<br>
I assume this is preliminary, but I wondered one thing about the API surface: why overload <code>+</code> and <code>-</code>, not <code>|</code> and <code>&amp;</code> and <code>!</code>? After all, the behavior is more like the bit operations than the arithmetic.<br>
In particular, while <code>bool</code> does not implement <code>+</code>, if it would then the mathematically "normal" thing to do (in my experience) would be to make this "addition modulo 2", ie. <code>true+true == false</code>. In that sense the proposed <code>+</code> for <code>Assume</code> behaves in unexpected ways.<br>
To make this point more concrete, I think when <code>+</code> and <code>-</code> are both defined, one can reasonably expect that <code>a+b-b == a</code>. (Algebraically speaking, this means <code>+</code> and <code>-</code> form a group. It is very uncommon to use <code>+</code> and <code>-</code> for operations that do not form a group. I know floating point types dont technically satisfy this, but they do "up to rounding and NaN".) For <code>Assume</code>, this condition is violated. I dont think libstd should do operator overloading like this.</p>



<a name="228951668"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/228951668" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Daniel Henry-Mantilla <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#228951668">(Mar 05 2021 at 13:23)</a>:</h4>
<p>I was gonna mention that bit ops may not read as well as good old "hand-waved set operations" such as <code>+</code> (for union) and <code>-</code> (for <code>\</code>), since not every Rust programmer is necessarily acquainted with bit-ops.</p>
<p>That being said, the case of quasi-forwarding a generic <code>&lt;const ASSUMPTIONS: Assume&gt;</code> parameter makes it so having the sigils ops showcase "group semantics" that actually do not hold may indeed be a footgun (although a somewhat realistic example of it being confusing would be nice to have for this discussion). Because of that, I now think that using <code>|</code> and <code>&amp;!</code>, even if it slightly hinders the readability, is the least dangerous course of action in the long term.</p>
<p>Also, we may consider that <a href="https://doc.rust-lang.org/stable/std/collections/struct.HashSet.html#trait-implementations">the impls on <code>std</code>'s <code>HashSet</code></a>  (and <code>BTreeSet</code>) may be have already set a precedent: have <code>And</code>, <code>Or</code>, <code>Xor</code>, and <code>Sub</code>, but no <code>Add</code>. Having <code>Or</code> and <code>Sub</code> (but no <code>Add</code>) seems like a good compromise indeed, since the op I was most worried about among the non-bitops-savy people was <code>&amp;!</code>.</p>



<a name="228992184"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/228992184" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#228992184">(Mar 05 2021 at 17:29)</a>:</h4>
<p>I also think it may be disproportionately likely that someone using safe-transmute (and especially with an assume parameter) will be familiar with bit operations.</p>



<a name="228997601"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/228997601" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#228997601">(Mar 05 2021 at 18:04)</a>:</h4>
<p>Previous conversation about <code>|</code>: <a href="#narrow/stream/213817-t-lang/topic/transmutability/near/226320883">https://rust-lang.zulipchat.com/#narrow/stream/213817-t-lang/topic/transmutability/near/226320883</a></p>



<a name="228997613"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/228997613" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Wrenn <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#228997613">(Mar 05 2021 at 18:04)</a>:</h4>
<p><span class="user-mention" data-user-id="120791">@RalfJ</span> happy to bikeshed on this. My bias is towards APIs that make some intuitive sense when read aloud. Admittedly, this is a matter of personal preference. I don't do a lot of bit manipulation.</p>
<p>How should the statement "assume all properties except alignment" translate into syntax?</p>
<ol>
<li>
<p><code>Assume::ALL &amp; !Assume::ALIGNMENT</code> reads as "assume all properties and not alignment".<br>
    Not too shabby! I doubt that people who don't do bit manipulation will intuitively come up with this arrangement of operators, but at least they won't be mislead if they encounter it in source code and simply read it aloud.</p>
</li>
<li>
<p><code>Assume::ALL - Assume::ALIGNMENT</code> reads as "assume all properties, minus alignment"<br>
    This is close to our target statement. Won't confuse bit-manip folks, but might confuse algebraists.</p>
</li>
</ol>
<p>How should the statement "assume alignment and validity" translate into syntax?</p>
<ol>
<li>
<p><code>Assume::ALIGNMENT | Assume::VALIDITY</code> reads as "assume alignment or validity"<br>
    Yikes. That is <em>very</em> misleading if you aren't accustomed to bit manipulation.</p>
</li>
<li>
<p><code>Assume::ALIGNMENT &amp; Assume::VALIDITY</code> reads as "assume alignment and validity"<br>
    This has the opposite problem: it matches out target statement exactly, but will confuse anyone accustomed bit manipulation.</p>
</li>
<li>
<p><code>Assume::ALIGNMENT + Assume::VALIDITY</code> reads as "assume alignment plus validity"<br>
    This is close to our target statement. Won't confuse bit-manip folks, but might confuse algebraists. </p>
</li>
</ol>
<p>In this toss-ups, <code>+</code> and <code>-</code> strike a balance between intelligibility when read aloud, and not confusing people who are used to thinking about bit manipulation.</p>
<p>This might confuse people who think of <code>+</code> as meaning "addition modulo 2", but that is already <em>not</em> the normal meaning of <code>+</code> in Rust. On the bare number types, <code>+</code> and <code>-</code> provide partial arithmetic. On <code>Wrapping&lt;T&gt;</code>, they provide wrapping arithmetic. My explanation of <code>+</code> and <code>-</code> on <code>Assume</code> for these folks would be: just think of it as a saturating addition, or saturating sub.</p>
<p>(Since <code>+</code> and <code>-</code> <em>aren't</em> defined on bare booleans, so hopefully the preconception that <code>+</code> and <code>-</code> on them would be wrapping is rare.)</p>



<a name="228997934"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/228997934" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#228997934">(Mar 05 2021 at 18:06)</a>:</h4>
<p><code>|</code> for meaning "both" is a widespread convention, though.  Even has a built-in attribute for it in C#: <a href="https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/enum#enumeration-types-as-bit-flags">https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/enum#enumeration-types-as-bit-flags</a></p>



<a name="228999504"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/228999504" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#228999504">(Mar 05 2021 at 18:16)</a>:</h4>
<p>Speaking as someone who intends to offer the easy interface on top of this intrinsic-y interface: bit ops would be totally fine to work with internally.</p>



<a name="228999817"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/228999817" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Wrenn <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#228999817">(Mar 05 2021 at 18:18)</a>:</h4>
<p>Sure. When you're thinking in terms of bit flags, it's the natural operator to use.</p>
<p>But the risks of misuse here are unequal enough that I think we'd do well to consider departing from that precedent:</p>
<ul>
<li>If we provide <code>+</code> instead of <code>|</code> we run the risk that people used to bit manipulation might reach for <code>|</code>, and would get an error message that it isn't defined for <code>Assume</code>(and perhaps a recommendation to use <code>+</code> instead!). The consequence is irritation.</li>
<li>If we provide <code>|</code> instead of <code>+</code>, we run the risk that people who <strong>aren't</strong> used to bit manipulation might read "Neglect::ALIGNMENT | Neglect::VALIDITY" aloud and get a <em>very</em> wrong impression. The consequence is, potentially, inadvertent unsoundness. </li>
</ul>
<p>The cognitive load of learning the arith ops vs the bit ops is unequal, too:</p>
<ul>
<li>The arithmetic route requires two operators: <code>+</code> and <code>-</code>, covering adding and removing assumptions, respectively.</li>
<li>The arithmetic route requires three operators: <code>&amp;</code>, <code>|</code> and <code>!</code>. The <code>!</code> operator isn't useful in isolation, so learning how to remove assumptions would require learning to correctly compose two operators, instead of one.</li>
</ul>



<a name="228999893"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/228999893" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#228999893">(Mar 05 2021 at 18:19)</a>:</h4>
<p>if you want the combinations to read aloud well, you should offer named methods that do the thing you want.</p>
<p>bikeshed time:</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">fn</span> <span class="nf">except_for</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span><span class="w"> </span><span class="n">bits_to_clear</span>: <span class="nc">Self</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="nc">Self</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">  </span><span class="bp">self</span><span class="w"> </span><span class="o">&amp;</span><span class="w"> </span><span class="o">!</span><span class="n">bits_to_clear</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="228999974"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/228999974" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#228999974">(Mar 05 2021 at 18:20)</a>:</h4>
<p>Assume::ALL.except_for(Assume::ALIGNMENT)</p>



<a name="229000059"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/229000059" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Wrenn <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#229000059">(Mar 05 2021 at 18:20)</a>:</h4>
<p>What would the named method be for adding an assumption?</p>



<a name="229000110"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/229000110" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#229000110">(Mar 05 2021 at 18:20)</a>:</h4>
<p>and_also</p>



<a name="229000209"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/229000209" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#229000209">(Mar 05 2021 at 18:21)</a>:</h4>
<p>that's the magic of bikeshed time jack! just make up anything on the spot, whatever feels good</p>



<a name="229000537"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/229000537" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Wrenn <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#229000537">(Mar 05 2021 at 18:23)</a>:</h4>
<p>haha. sure. i was absolutely committing entrapment by prodding you on this. I would have guessed <code>and</code>, which has some obvious potential for confusion. <code>and_also</code> isn't too shabby.</p>



<a name="229000598"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/229000598" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Wrenn <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#229000598">(Mar 05 2021 at 18:23)</a>:</h4>
<p>however, i think you mean:</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="n">Assume</span>::<span class="n">ALL</span><span class="p">.</span><span class="n">yeet</span><span class="p">(</span><span class="n">Assume</span>::<span class="n">ALIGNMENT</span><span class="p">)</span><span class="w"></span>
</code></pre></div>



<a name="229001186"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/229001186" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#229001186">(Mar 05 2021 at 18:27)</a>:</h4>
<p>yeet is obviously a future keyword so we shouldn't use it for methods.</p>



<a name="229002839"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/229002839" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#229002839">(Mar 05 2021 at 18:37)</a>:</h4>
<p><span class="user-mention" data-user-id="219211">@Jack Wrenn</span> I do think the "read aloud" problem is important here.</p>



<a name="229002926"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/229002926" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#229002926">(Mar 05 2021 at 18:37)</a>:</h4>
<p>I don't mind "this is only familiar to people who have used bit operations". I do mind "this is actively harmful and illogical to people who haven't used bit operations".</p>



<a name="229003004"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/229003004" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#229003004">(Mar 05 2021 at 18:38)</a>:</h4>
<p><span class="user-mention silent" data-user-id="219211">Jack Wrenn</span> <a href="#narrow/stream/213817-t-lang/topic/transmutability/near/228999817">said</a>:</p>
<blockquote>
<p>But the risks of misuse here are unequal enough that I think we'd do well to consider departing from that precedent:</p>
</blockquote>
<p>I think one can easily get the problems in the other way arriving from simd or linear algebra, though.  The common definition for <code>+</code> on something like a struct with <code>x/y/z</code> or <code>r/g/b</code> fields would be mapping the operator over those fields -- see all the complaints about <code>+</code> on <code>String</code> because it doesn't work like that -- and the fact that this wouldn't be doing that gets back to all the things that Ralf was talking about.</p>



<a name="229003070"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/229003070" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#229003070">(Mar 05 2021 at 18:38)</a>:</h4>
<p>I think that rules out &amp; because it reads differently than its bit-op meaning.</p>



<a name="229003141"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/229003141" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#229003141">(Mar 05 2021 at 18:39)</a>:</h4>
<p>And I would lean against | because it will actively confuse people who don't know bit ops.</p>



<a name="229003217"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/229003217" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#229003217">(Mar 05 2021 at 18:39)</a>:</h4>
<p>If we suppose that the various assume flags are in fact numeric bit flags (which they aren't), + is actually valid to combine them.</p>



<a name="229003304"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/229003304" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#229003304">(Mar 05 2021 at 18:40)</a>:</h4>
<p>So it makes sense to both groups, and I don't think it's <em>wrong</em> for either.</p>



<a name="229003308"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/229003308" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#229003308">(Mar 05 2021 at 18:40)</a>:</h4>
<p><span class="user-mention silent" data-user-id="239881">Josh Triplett</span> <a href="#narrow/stream/213817-t-lang/topic/transmutability/near/229003217">said</a>:</p>
<blockquote>
<p>If we suppose that the various assume flags are in fact numeric bit flags (which they aren't), + is actually valid to combine them.</p>
</blockquote>
<p>Until you add something twice and it carries into a different flag...</p>



<a name="229003461"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/229003461" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#229003461">(Mar 05 2021 at 18:41)</a>:</h4>
<p>Sure, but I don't think people will assume that about assume.</p>



<a name="229003469"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/229003469" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#229003469">(Mar 05 2021 at 18:41)</a>:</h4>
<p>Pondering: is it possible that the negative phrasing here (<code>Neglect::NONE</code> vs <code>Enforce::EVERYTHING</code>) is making this more difficult?</p>



<a name="229003622"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/229003622" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#229003622">(Mar 05 2021 at 18:42)</a>:</h4>
<p>"assume" seems clearer than "neglect" here.</p>



<a name="229003734"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/229003734" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#229003734">(Mar 05 2021 at 18:43)</a>:</h4>
<p>When this was trait "addition" the neglect direction made sense, as there's no trait subtraction.  But maybe the other phrasing could help with naming things</p>



<a name="229003754"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/229003754" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#229003754">(Mar 05 2021 at 18:43)</a>:</h4>
<p>(Though of course for the MCP naming is largely irrelevant)</p>



<a name="229004214"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/229004214" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Wrenn <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#229004214">(Mar 05 2021 at 18:46)</a>:</h4>
<p>Hm, I don't <em>think</em> reversing polarity changes much in this regard? You still end up with situations where you need to add or remove a static check, so you still need a syntax for doing that. The meaning of the syntax just gets reversed.</p>



<a name="229059465"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/229059465" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#229059465">(Mar 06 2021 at 03:22)</a>:</h4>
<p>Well, the issue you brought up with the "reading" being opposite of the bit operator sense of <code>|</code> and <code>&amp;</code> would be fixed by a polarity change</p>



<a name="229088319"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/229088319" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#229088319">(Mar 06 2021 at 10:56)</a>:</h4>
<p><span class="user-mention silent" data-user-id="239881">Josh Triplett</span> <a href="#narrow/stream/213817-t-lang/topic/transmutability/near/229002926">said</a>:</p>
<blockquote>
<p>I don't mind "this is only familiar to people who have used bit operations". I do mind "this is actively harmful and illogical to people who haven't used bit operations".</p>
</blockquote>
<p>how's that any worse than <code>if a &amp;&amp; b { X }</code> being read aloud as "X is done under conditions a and b", which most non-mathematically minded people say when they really mean <code>if a || b { X }</code>? There is, sadly, in common speech a confusion of "union" and "and", despite the fact that logically, "union = or" and "intersection = and". (I guess the underlying issue here is that "and" has a logical meaning of intersection but an arithmetic meaning of "combining things".) But given that we already use <code>||</code> to mean "or" aka "union", I don't think we should use <code>+</code> to also mean "union". That's just very confusing to anyone who does think in mathematical/logical terms, which programmers are more likely to do that the average person.<br>
I don't think there is a way to make the "common speech interpretation of the operation said out aloud" always match what actually happens, because common speech is internally inconsistent. So absent that I'd prefer to at least be mathematically/logically consistent: if both <code>+</code> and <code>-</code> exist, the latter should be the inverse of the former.</p>
<p>As was mentioned above, some people already get confused by <code>+</code> on strings, I think this is worse (at least we don't have <code>-</code> on strings, and <code>+</code> on strings forms a monoid so the notation makes some mathemetical sense).</p>



<a name="229088374"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/229088374" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#229088374">(Mar 06 2021 at 10:57)</a>:</h4>
<p><span class="user-mention silent" data-user-id="239881">Josh Triplett</span> <a href="#narrow/stream/213817-t-lang/topic/transmutability/near/229003217">said</a>:</p>
<blockquote>
<p>If we suppose that the various assume flags are in fact numeric bit flags (which they aren't), + is actually valid to combine them.</p>
</blockquote>
<p>they dont behave like numeric bit flags at all though as <code>-</code> shows, so this is saying "if we suppose an actively wrong mental model then ...", which I don't think is a good argument.</p>



<a name="229111402"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/229111402" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oliver <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#229111402">(Mar 06 2021 at 16:44)</a>:</h4>
<p>is there some reason that <code>*</code> hasn't been proposed?</p>



<a name="229112600"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/229112600" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#229112600">(Mar 06 2021 at 17:02)</a>:</h4>
<p>I'd like to observe that this seems like the height (or perhaps, the depths) of bikeshedding.</p>



<a name="229112696"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/229112696" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#229112696">(Mar 06 2021 at 17:04)</a>:</h4>
<p>At this point, arguments have been made; let's leave it to the group what to propose.</p>



<a name="229113797"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/229113797" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oliver <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#229113797">(Mar 06 2021 at 17:19)</a>:</h4>
<p>at least that's not obvious to me anyway</p>



<a name="229124962"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/229124962" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Wrenn <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#229124962">(Mar 06 2021 at 20:06)</a>:</h4>
<p><span class="user-mention" data-user-id="281739">@oliver</span> We need syntax for: </p>
<ol>
<li>adding an assumption to the set of assumptions</li>
<li>removing an assumption from the set of assumptions</li>
</ol>
<p>Which one of those would <code>*</code> correspond to?</p>



<a name="229126405"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/229126405" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Wrenn <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#229126405">(Mar 06 2021 at 20:27)</a>:</h4>
<p><span class="user-mention" data-user-id="120791">@RalfJ</span> Do you have any objections to using <code>|</code> for adding assumptions and <code>-</code> for removing assumptions?</p>



<a name="229127039"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/229127039" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oliver <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#229127039">(Mar 06 2021 at 20:36)</a>:</h4>
<p><code>*</code> is well-known for multiplication over a type and <code>\</code> is known for removing elements</p>



<a name="229127168"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/229127168" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#229127168">(Mar 06 2021 at 20:39)</a>:</h4>
<p><span class="user-mention" data-user-id="219211">@Jack Wrenn</span> I think if we're going to assume that people understand <code>-</code> to remove assumptions, we might as well use <code>+</code> to add assumptions.</p>



<a name="229127377"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/229127377" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Wrenn <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#229127377">(Mar 06 2021 at 20:41)</a>:</h4>
<p>I personally agree, but having <code>|</code> and <code>-</code> is the compromise <a href="#narrow/stream/213817-t-lang/topic/transmutability/near/228951668">suggested</a> by <span class="user-mention" data-user-id="232018">@Daniel Henry-Mantilla</span> to match <code>HashSet</code>, which defines <code>|</code> and <code>-</code>, but <em>not</em> <code>+</code>.</p>



<a name="229127451"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/229127451" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#229127451">(Mar 06 2021 at 20:42)</a>:</h4>
<p>Ah, I didn't realize that was the motivation.</p>



<a name="229127476"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/229127476" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Wrenn <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#229127476">(Mar 06 2021 at 20:42)</a>:</h4>
<p>And <span class="user-mention" data-user-id="120791">@RalfJ</span>'s criticism was:</p>
<blockquote>
<p>if both <code>+</code> and <code>-</code> exist, the latter should be the inverse of the former.</p>
</blockquote>
<p>...so this might be only a problem posed by the <em>coexistence</em> of <code>+</code> and <code>-</code>.</p>



<a name="229127503"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/229127503" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#229127503">(Mar 06 2021 at 20:43)</a>:</h4>
<p>That one I don't understand; I feel like they <em>are</em> inverses.</p>



<a name="229127510"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/229127510" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#229127510">(Mar 06 2021 at 20:43)</a>:</h4>
<p><code>X + Y - Y</code> is X.</p>



<a name="229127655"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/229127655" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Wrenn <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#229127655">(Mar 06 2021 at 20:45)</a>:</h4>
<p>I think the difference is with the over/underflow conditions? For <code>+</code> and <code>-</code> to be true inverses, they need to behave like wrapping arithmetic. On <code>Assume</code>, they behave like saturating arithmetic.</p>



<a name="229127737"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/229127737" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#229127737">(Mar 06 2021 at 20:46)</a>:</h4>
<p>Sure.</p>



<a name="229127844"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/229127844" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Wrenn <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#229127844">(Mar 06 2021 at 20:48)</a>:</h4>
<p>To me, that's not that weird, but <span aria-label="shrug" class="emoji emoji-1f937" role="img" title="shrug">:shrug:</span></p>



<a name="229127991"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/229127991" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#229127991">(Mar 06 2021 at 20:49)</a>:</h4>
<p><span class="user-mention silent" data-user-id="239881">Josh Triplett</span> <a href="#narrow/stream/213817-t-lang/topic/transmutability/near/229127510">said</a>:</p>
<blockquote>
<p><code>X + Y - Y</code> is X.</p>
</blockquote>
<p>it's not though. If <code>X</code> is all-true and <code>Y</code> is all-true then <code>X+Y-Y</code> is all-false.<br>
So, they are definitely not inverses in any sense of the word I can imagine.</p>



<a name="229128079"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/229128079" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Wrenn <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#229128079">(Mar 06 2021 at 20:50)</a>:</h4>
<p>That's the wrapping vs. saturating distinction, right?</p>



<a name="229128080"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/229128080" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#229128080">(Mar 06 2021 at 20:50)</a>:</h4>
<p><span class="user-mention silent" data-user-id="281739">oliver</span> <a href="#narrow/stream/213817-t-lang/topic/transmutability/near/229127039">said</a>:</p>
<blockquote>
<p><code>*</code> is well-known for multiplication over a type and <code>\</code> is known for removing elements</p>
</blockquote>
<p>sure, but multiplication corrsponds to <code>&amp;</code>, so I don't see how that helps. and yes <code>\</code> would be great but we don't have that operator in Rust.</p>



<a name="229128106"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/229128106" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oliver <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#229128106">(Mar 06 2021 at 20:51)</a>:</h4>
<p>that's a shame :(</p>



<a name="229128126"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/229128126" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Wrenn <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#229128126">(Mar 06 2021 at 20:51)</a>:</h4>
<p>/me files an RFC to add <code>\</code></p>



<a name="229128129"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/229128129" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#229128129">(Mar 06 2021 at 20:51)</a>:</h4>
<p><span class="user-mention silent" data-user-id="219211">Jack Wrenn</span> <a href="#narrow/stream/213817-t-lang/topic/transmutability/near/229128079">said</a>:</p>
<blockquote>
<p>That's the wrapping vs. saturating distinction, right?</p>
</blockquote>
<p>you mean in the sense that saturating arithmetic also fails to be a group?</p>



<a name="229128137"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/229128137" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oliver <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#229128137">(Mar 06 2021 at 20:51)</a>:</h4>
<p><code>*</code> for multiplication over sets of types*</p>



<a name="229128183"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/229128183" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Wrenn <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#229128183">(Mar 06 2021 at 20:52)</a>:</h4>
<p><span class="user-mention" data-user-id="120791">@RalfJ</span> yep.</p>



<a name="229128194"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/229128194" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oliver <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#229128194">(Mar 06 2021 at 20:52)</a>:</h4>
<p>probably still off*</p>



<a name="229128221"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/229128221" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#229128221">(Mar 06 2021 at 20:52)</a>:</h4>
<p>yes. I am not sure what the right algebraic structure is to describe saturating arithmetic.</p>



<a name="229128255"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/229128255" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Wrenn <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#229128255">(Mar 06 2021 at 20:53)</a>:</h4>
<p>Currently, all of the primitive numeric types implement partial arithmetic (panic on underflow and overflow), so they also fail to be a group, right?</p>



<a name="229128256"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/229128256" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#229128256">(Mar 06 2021 at 20:53)</a>:</h4>
<p>unlike modular arithmetic, I have not seen it (saturating arithmetic) come up in formal math/CS</p>



<a name="229128261"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/229128261" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#229128261">(Mar 06 2021 at 20:53)</a>:</h4>
<p><span class="user-mention silent" data-user-id="219211">Jack Wrenn</span> <a href="#narrow/stream/213817-t-lang/topic/transmutability/near/229128255">said</a>:</p>
<blockquote>
<p>Currently, all of the primitive numeric types implement partial arithmetic (panic on underflow and overflow), so they also fail to be a group, right?</p>
</blockquote>
<p>they are a partial group</p>



<a name="229128349"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/229128349" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Wrenn <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#229128349">(Mar 06 2021 at 20:54)</a>:</h4>
<p>Huh, gotcha.</p>



<a name="229128381"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/229128381" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#229128381">(Mar 06 2021 at 20:54)</a>:</h4>
<p><span class="user-mention silent" data-user-id="219211">Jack Wrenn</span> <a href="#narrow/stream/213817-t-lang/topic/transmutability/near/229126405">said</a>:</p>
<blockquote>
<p><span class="user-mention silent" data-user-id="120791">RalfJ</span> Do you have any objections to using <code>|</code> for adding assumptions and <code>-</code> for removing assumptions?</p>
</blockquote>
<p>no objections other than a vague sense of weirdness. I think when I saw those I would be like "hu, what's going on here" and read the docs, which is probably the intended result. ;)</p>



<a name="229128441"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/229128441" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#229128441">(Mar 06 2021 at 20:55)</a>:</h4>
<p>I was not even aware our HashSet overloads operations, and I am not sure I'd use them in code I write</p>



<a name="229128449"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/229128449" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Wrenn <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#229128449">(Mar 06 2021 at 20:55)</a>:</h4>
<p>Wouldn't you react similarly if you reached for <code>|</code> and got an error message that it wasn't defined?</p>



<a name="229128450"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/229128450" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#229128450">(Mar 06 2021 at 20:55)</a>:</h4>
<p>(just like I wouldnt use <code>+</code> on strings)</p>



<a name="229128471"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/229128471" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#229128471">(Mar 06 2021 at 20:55)</a>:</h4>
<p><span class="user-mention silent" data-user-id="219211">Jack Wrenn</span> <a href="#narrow/stream/213817-t-lang/topic/transmutability/near/229128449">said</a>:</p>
<blockquote>
<p>Wouldn't you react similarly if you reached for <code>|</code> and got an error message that it wasn't defined?</p>
</blockquote>
<p>honestly I wouldnt usually reach for overloaded operators, I'd reach for named methods</p>



<a name="229128567"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/229128567" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Wrenn <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#229128567">(Mar 06 2021 at 20:57)</a>:</h4>
<p>I don't have any objections to also supply named methods for these operations, for those with that preference.</p>



<a name="229128590"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/229128590" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#229128590">(Mar 06 2021 at 20:57)</a>:</h4>
<p>it's not like I fundamentally dislike operator overloading, in my research I am using unicode operator notation for all sorts of things -- but then we use <code>∪</code> for union and  <code>∖</code> for difference, we'd never overload the arithmetic operators like that ;)</p>



<a name="229128659"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/229128659" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#229128659">(Mar 06 2021 at 20:58)</a>:</h4>
<p>but of course in Rust we don't have that option</p>



<a name="229128673"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/229128673" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Wrenn <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#229128673">(Mar 06 2021 at 20:58)</a>:</h4>
<p><em>yet</em> <span aria-label="wink" class="emoji emoji-1f609" role="img" title="wink">:wink:</span></p>



<a name="229128675"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/229128675" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#229128675">(Mar 06 2021 at 20:58)</a>:</h4>
<p>which is why I reach for named things as the next best option. C++ <code>std::cout &lt;&lt; foo</code> showed what can happen when you push operator overloading too far ;)</p>



<a name="229128678"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/229128678" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#229128678">(Mar 06 2021 at 20:59)</a>:</h4>
<p><span class="user-mention silent" data-user-id="219211">Jack Wrenn</span> <a href="#narrow/stream/213817-t-lang/topic/transmutability/near/229128673">said</a>:</p>
<blockquote>
<p><em>yet</em> <span aria-label="wink" class="emoji emoji-1f609" role="img" title="wink">:wink:</span></p>
</blockquote>
<p>nopenopenope</p>



<a name="229128704"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/229128704" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Wrenn <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#229128704">(Mar 06 2021 at 20:59)</a>:</h4>
<p>hahahaha.</p>



<a name="229128715"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/229128715" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#229128715">(Mar 06 2021 at 20:59)</a>:</h4>
<p>I've used Haskell codebases with arbitrary Unicode operators, and even just arbitrary ASCII operators. Nope nope nope.</p>



<a name="229128721"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/229128721" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Wrenn <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#229128721">(Mar 06 2021 at 20:59)</a>:</h4>
<p>:trollface:</p>



<a name="229128726"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/229128726" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#229128726">(Mar 06 2021 at 21:00)</a>:</h4>
<p>It worked in the Haskell world where a substantial fraction of packages had someone's thesis as their documentation. ;)</p>



<a name="229128791"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/229128791" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Wrenn <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#229128791">(Mar 06 2021 at 21:00)</a>:</h4>
<p>Josh Triplett has <em>seen</em> things, man.</p>



<a name="229128827"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/229128827" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#229128827">(Mar 06 2021 at 21:00)</a>:</h4>
<p>yeah in case of the research I mentioned above that would be my thesis ;)</p>



<a name="229128880"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/229128880" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#229128880">(Mar 06 2021 at 21:01)</a>:</h4>
<p><span class="user-mention silent" data-user-id="120791">RalfJ</span> <a href="#narrow/stream/213817-t-lang/topic/transmutability/near/229128827">said</a>:</p>
<blockquote>
<p>yeah in case of the research I mentioned above that would be my thesis ;)</p>
</blockquote>
<p>I deeply appreciate that a substantial part of your work is making your results accessible to a broad audience.</p>



<a name="229128952"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/229128952" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#229128952">(Mar 06 2021 at 21:02)</a>:</h4>
<p>In any case, as tempted as I've occasionally been, I think the general consensus is strongly against arbitrary overloadable operators.</p>



<a name="229128964"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/229128964" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#229128964">(Mar 06 2021 at 21:02)</a>:</h4>
<p>but anyway, back on topic -- if having <code>+</code>and <code>-</code> violate the axioms of a (partial) group is considered acceptable, e.g. for use in a "saturating semantics", then so be it. it's a line being crossed but it's not the end of the world and I'll get used to it. I just wanted to make sure that this is a deliberate move. :)</p>



<a name="229129085"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/229129085" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#229129085">(Mar 06 2021 at 21:04)</a>:</h4>
<p><span class="user-mention silent" data-user-id="239881">Josh Triplett</span> <a href="#narrow/stream/213817-t-lang/topic/transmutability/near/229128880">said</a>:</p>
<blockquote>
<p>I deeply appreciate that a substantial part of your work is making your results accessible to a broad audience.</p>
</blockquote>
<p><span aria-label="heart" class="emoji emoji-2764" role="img" title="heart">:heart:</span> but you can't mean my thesis with that, I'd call it many things but not broadly accessible ;)</p>



<a name="229129628"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/229129628" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#229129628">(Mar 06 2021 at 21:13)</a>:</h4>
<p><span class="user-mention silent" data-user-id="120791">RalfJ</span> <a href="#narrow/stream/213817-t-lang/topic/transmutability/near/229129085">said</a>:</p>
<blockquote>
<p><span class="user-mention silent" data-user-id="239881">Josh Triplett</span> <a href="#narrow/stream/213817-t-lang/topic/transmutability/near/229128880">said</a>:</p>
<blockquote>
<p>I deeply appreciate that a substantial part of your work is making your results accessible to a broad audience.</p>
</blockquote>
<p><span aria-label="heart" class="emoji emoji-2764" role="img" title="heart">:heart:</span> but you can't mean my thesis with that, I'd call it many things but not broadly accessible ;)</p>
</blockquote>
<p>I mean your work in general. You're focused heavily on practical applications, clear semantics, <em>understanding</em>, and meeting people where they are; that puts you in the top tier of formal-methods folks.</p>



<a name="229129752"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/229129752" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#229129752">(Mar 06 2021 at 21:14)</a>:</h4>
<p>put me down with jack: pro-operators. everything <em>can</em> be used wrong, i trust people to be sensible (or their crates will just be unpopular and their download count won't <span aria-label="rocket" class="emoji emoji-1f680" role="img" title="rocket">:rocket:</span><span aria-label="rocket" class="emoji emoji-1f680" role="img" title="rocket">:rocket:</span><span aria-label="rocket" class="emoji emoji-1f680" role="img" title="rocket">:rocket:</span>).</p>



<a name="229129789"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/229129789" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#229129789">(Mar 06 2021 at 21:15)</a>:</h4>
<p>that said, for this assume thing, start with word methods only, no + or | or anything like that</p>



<a name="229129806"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/229129806" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Wrenn <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#229129806">(Mar 06 2021 at 21:15)</a>:</h4>
<p>I think I have a good enough understanding of the tradeoffs of each approach to write something that adequately contrasts them, which will be useful for the libs team if this proposal is ever RFC'd. For now, it's almost a moot point.</p>
<p>I'm going to keep the MCP as-is for now, but when it comes to implementation, we can even do silly things like implement <em>all</em> of the different proposals just so we can play around with how they feel in practice. Of course we'll need to eventually whittle that down, but that's a long way off.</p>



<a name="229129896"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/229129896" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Wrenn <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#229129896">(Mar 06 2021 at 21:17)</a>:</h4>
<p><span class="user-mention" data-user-id="224471">@Lokathor</span> I would have done that in the MCP if the ergonomics of calling methods in const-generic positions weren't <em>so</em> bad. Brevity and clarity go hand-in-hand when it comes to types.</p>



<a name="229129979"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/229129979" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#229129979">(Mar 06 2021 at 21:18)</a>:</h4>
<p>it's kinda bad, usually you can define the ones you want and use named values:</p>
<p>const Foo: t = complicated.expression().here();<br>
thing::&lt;Foo&gt;(x);</p>



<a name="229130175"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/229130175" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Wrenn <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#229130175">(Mar 06 2021 at 21:21)</a>:</h4>
<p>It gets especially rough in <code>where</code> bounds, and when some aspect of the expression is a variable (e.g., <code>ASSUME + Assume::ALIGNMENT</code>). In those cases, you need to define a <code>const fn</code> in the surrounding scope, and introduce indirection into your <code>where</code> bound.</p>



<a name="229130283"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/229130283" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#229130283">(Mar 06 2021 at 21:23)</a>:</h4>
<p>as with most of programming, the only thing worse than const generics is not having const generics.</p>



<a name="229130367"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/229130367" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#229130367">(Mar 06 2021 at 21:24)</a>:</h4>
<p>those are all just limitations of the current implementation though, right? should that really inform API design?</p>



<a name="229130419"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/229130419" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Wrenn <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#229130419">(Mar 06 2021 at 21:25)</a>:</h4>
<p>I'm just commenting on the aesthetics, not whether or not you <em>can</em> call const methods in const generic positions (as far as I'm aware: you can).</p>



<a name="229130427"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/229130427" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#229130427">(Mar 06 2021 at 21:25)</a>:</h4>
<p>for Nightly: yes absolutely it should inform, we must always live in the world we have.</p>
<p>for stabilization: probably not, if we can wait a bit to get a better api.</p>



<a name="229130486"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/229130486" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#229130486">(Mar 06 2021 at 21:26)</a>:</h4>
<p>fair</p>



<a name="229130528"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/229130528" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#229130528">(Mar 06 2021 at 21:27)</a>:</h4>
<p>we're also, for example, doing some un-nice temporary things in the simd-wg until stuff gets fixed in rustc/llvm/cranelift.</p>



<a name="229151278"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/229151278" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#229151278">(Mar 07 2021 at 03:18)</a>:</h4>
<p>There's also my plan for <code>Try</code>: propose something, change it to something completely different names, then just go to a libs meeting and say "so what should it be, folks?" <span aria-label="smirk" class="emoji emoji-1f60f" role="img" title="smirk">:smirk:</span></p>



<a name="229151645"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/229151645" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#229151645">(Mar 07 2021 at 03:24)</a>:</h4>
<p><span class="user-mention silent" data-user-id="120791">RalfJ</span> <a href="#narrow/stream/213817-t-lang/topic/transmutability/near/229128256">said</a>:</p>
<blockquote>
<p>unlike modular arithmetic, I have not seen it (saturating arithmetic) come up in formal math/CS</p>
</blockquote>
<p>FWIW I have seen saturating arithmetic come up in formal math, and it's <code>+</code> and <code>-</code>. In this case I would describe the operators more like set operators but I don't think <code>∪</code> and <code>\</code> are an option. The correct cancellation equation is <code>A + B - B = A - B</code> BTW, this is just like on sets. It is cancellative on the assumption that B is disjoint from A: <code>B &amp; A = 0 -&gt; A + B - B = A</code></p>



<a name="229170326"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/229170326" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#229170326">(Mar 07 2021 at 08:48)</a>:</h4>
<p><span class="user-mention" data-user-id="125270">@scottmcm</span> Yeah, but we were on to you, hence the response of "here are some criteria, you come back with new names". ;)</p>



<a name="229176686"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/229176686" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#229176686">(Mar 07 2021 at 10:33)</a>:</h4>
<p><span class="user-mention" data-user-id="271719">@Mario Carneiro</span> </p>
<blockquote>
<p>The correct cancellation equation is A + B - B = A - B</p>
</blockquote>
<p>This does not hold for saturating arithmetic: take A = 10 and B = 2 and use u32 saturating arithmetic.<br>
So I dont think it is the right equation.</p>



<a name="229176795"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/229176795" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#229176795">(Mar 07 2021 at 10:34)</a>:</h4>
<p>Also, the term "cancellative" in my world usually refers to <code>A + B = A + C → B = C</code> (which is weaker than actually having an inverse) so I am a bit confused by your use of the term. ;)</p>



<a name="229180431"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/229180431" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#229180431">(Mar 07 2021 at 11:32)</a>:</h4>
<blockquote>
<p>This does not hold for saturating arithmetic: take A = 10 and B = 2 and use u32 saturating arithmetic. So I dont think it is the right equation.</p>
</blockquote>
<p>That's true, but this isn't any old saturating arithmetic, it's a boolean algebra</p>



<a name="229180636"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/229180636" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#229180636">(Mar 07 2021 at 11:35)</a>:</h4>
<p>I mean cancellation only in the sense that it is a simplification of a cancellation equation. Obviously neither boolean algebras nor saturating semirings are cancellative in the full sense, although most have something approximating a cancellation law, like this one</p>



<a name="229180709"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/229180709" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#229180709">(Mar 07 2021 at 11:36)</a>:</h4>
<p>with saturating u32 the cancellation law holds under some messy inequality side conditions</p>



<a name="229180827"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/229180827" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#229180827">(Mar 07 2021 at 11:39)</a>:</h4>
<blockquote>
<p>That's true, but this isn't any old saturating arithmetic, it's a boolean algebra</p>
</blockquote>
<p>sure it is, but in programming we usually write <code>|</code> and <code>&amp;</code> for the boolean operations. that's the entire point. ;)</p>



<a name="229181457"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/229181457" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#229181457">(Mar 07 2021 at 11:48)</a>:</h4>
<p>Personally, I would be fine with either <code>|</code> and <code>&amp;!</code> or <code>+</code> and <code>-</code>. Although if this is going to have the full suite of boolean operators then there are some terms you can make that aren't just "assume none + these enumerated things", like "assume everything except this" (i.e. if you just use <code>!</code>). If only <code>+</code> and <code>-</code> are exposed then you can't write these, which may or may not be considered a good thing</p>



<a name="229200413"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/229200413" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#229200413">(Mar 07 2021 at 16:39)</a>:</h4>
<p>Personally I would be very surprised that + and - had boolean semantics. I would rather use &amp; and | for that - if you've never seen them before it will hopefully make you go read the docs, and if you have I don't think you'd be confused about the behavior</p>



<a name="229200564"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/229200564" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#229200564">(Mar 07 2021 at 16:41)</a>:</h4>
<p>That said, being consistent with HashSet also sounds nice</p>



<a name="240901455"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/240901455" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Sergio <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#240901455">(Jun 01 2021 at 06:58)</a>:</h4>
<p><span class="user-mention silent" data-user-id="125270">scottmcm</span> <a href="#narrow/stream/213817-t-lang/topic/transmutability/near/225927371">said</a>:</p>
<blockquote>
<p><span class="user-mention silent" data-user-id="219211">Jack Wrenn</span> <a href="#narrow/stream/213817-t-lang/topic/transmutability/near/225924998">said</a>:</p>
<blockquote>
<p>I noticed that. Is that limitation just an over-zealous lint? There isn't any stability hazard there that I can see.</p>
</blockquote>
<p>This is the classic "FRU doesn't work like everyone expects".</p>
<p>The desugar moves all the fields that aren't mentioned, and <code>non_exhaustive</code> doesn't promise that those will be public.</p>
</blockquote>
<p>Why does this mean that <code>Foo { public, ..rest() }</code> shouldn't work when <code>Foo</code> is <code>#[non_exhaustive]</code>? I'm failing to see the hazard myself.</p>



<a name="240905473"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/transmutability/near/240905473" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/transmutability.html#240905473">(Jun 01 2021 at 07:46)</a>:</h4>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">mod</span> <span class="nn">foo</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">pub</span><span class="w"> </span><span class="k">struct</span> <span class="nc">Foo</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="k">pub</span><span class="w"> </span><span class="n">public</span>: <span class="kt">u8</span><span class="p">,</span><span class="w"></span>
<span class="w">        </span><span class="n">private</span>: <span class="kt">u8</span><span class="p">,</span><span class="w"></span>
<span class="w">    </span><span class="p">}</span><span class="w"></span>

<span class="w">    </span><span class="k">pub</span><span class="w"> </span><span class="k">fn</span> <span class="nf">rest</span><span class="p">()</span><span class="w"> </span>-&gt; <span class="nc">Foo</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="fm">todo!</span><span class="p">()</span><span class="w"> </span><span class="p">}</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
<span class="k">use</span><span class="w"> </span><span class="n">foo</span>::<span class="o">*</span><span class="p">;</span><span class="w"></span>

<span class="k">fn</span> <span class="nf">main</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="n">Foo</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="n">public</span>: <span class="mi">0</span><span class="p">,</span><span class="w"> </span><span class="o">..</span><span class="n">rest</span><span class="p">()</span><span class="w"> </span><span class="p">};</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>
<p>gives</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="n">error</span><span class="p">[</span><span class="n">E0451</span><span class="p">]</span>: <span class="nc">field</span><span class="w"> </span><span class="err">`</span><span class="n">private</span><span class="err">`</span><span class="w"> </span><span class="n">of</span><span class="w"> </span><span class="k">struct</span> <span class="err">`</span><span class="n">foo</span>::<span class="n">Foo</span><span class="err">`</span><span class="w"> </span><span class="n">is</span><span class="w"> </span><span class="n">private</span><span class="w"></span>
<span class="w">  </span><span class="o">-</span>-&gt; <span class="nc">src</span><span class="o">/</span><span class="n">main</span><span class="p">.</span><span class="n">rs</span>:<span class="mi">12</span>:<span class="mi">24</span><span class="w"></span>
<span class="w">   </span><span class="o">|</span><span class="w"></span>
<span class="mi">12</span><span class="w"> </span><span class="o">|</span><span class="w">     </span><span class="n">Foo</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="n">public</span>: <span class="mi">0</span><span class="p">,</span><span class="w"> </span><span class="o">..</span><span class="n">rest</span><span class="p">()</span><span class="w"> </span><span class="p">};</span><span class="w"></span>
<span class="w">   </span><span class="o">|</span><span class="w">                        </span><span class="o">^^^^^^</span><span class="w"> </span><span class="n">field</span><span class="w"> </span><span class="err">`</span><span class="n">private</span><span class="err">`</span><span class="w"> </span><span class="n">is</span><span class="w"> </span><span class="n">private</span><span class="w"></span>
</code></pre></div>
<p><code>#[non_exhaustive]</code> doesn't guarantee that <code>struct Foo { pub public: u8 }</code> doesn't turn into <code>struct Foo { pub public: u8, private: u8 }</code>, which would break FRU.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>